package org.musicsweet.controller;

import org.musicsweet.anotation.AuthReq;
import org.musicsweet.entity.SysRole;
import org.musicsweet.result.ResultData;
import org.musicsweet.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sysRole")
public class SysRoleController {


    @Autowired
    private SysRoleService sysRoleService;

    /**
     * 根据id查询系统角色
     * @param sysRole
     * @return
     */
    @AuthReq
    @RequestMapping("/getSysRoleById")
    public ResultData<SysRole> getSysRoleById(@RequestBody SysRole sysRole) {
        return sysRoleService.getSysRoleById(sysRole);
    }

    /**
     * 多条件查询系统角色
     * @param sysRole
     * @return
     */
    @AuthReq
    @RequestMapping("/getSysRoleList")
    public ResultData<List<SysRole>> getSysRoleList(@RequestBody SysRole sysRole) {
        return sysRoleService.getSysRoleList(sysRole);
    }


    /**
     * 添加系统角色
     * @param sysRole
     * @param token
     * @return
     */
    @RequestMapping("/addSysRole")
    public ResultData addSysRole(@RequestBody SysRole sysRole,String token) {
        return sysRoleService.addSysRole(sysRole,token);
    }


    /**
     * 修改系统角色
     * @param sysRole
     * @param token
     * @return
     */
    @RequestMapping("/updateSysRole")
    public ResultData updateSysRole(@RequestBody SysRole sysRole,String token) {
        return sysRoleService.updateSysRole(sysRole,token);
    }


    /**
     * 删除系统角色
     * @param sysRole
     * @return
     */
    @RequestMapping("/delSysRole")
    public ResultData delSysRole(@RequestBody SysRole sysRole) {
        return sysRoleService.delSysRole(sysRole);
    }

}
